package com.dandelion.business.controller;


import cn.hutool.json.JSONUtil;
import com.dandelion.framework.common.R;
import com.dandelion.business.service.UserLoginService;
import com.dandelion.business.entity.vo.login.req.LoginReqVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Api(tags = "登录模块")
@Slf4j
@RestController
@RequestMapping("/user")
public class LoginController {


    @Autowired
    private UserLoginService userLoginService;


    @ApiOperation("登录系统")
    @PostMapping("/login")
    public R login(@RequestBody LoginReqVO req) {
        log.info("登录请求:{}", JSONUtil.toJsonStr(req));
        return userLoginService.login(req);
    }

    @ApiOperation("登出系统")
    @PostMapping("/logout")
    public R logout() {
        return userLoginService.logout();
    }
}
